package persistence;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import entity.Cliente;

public class ClienteDao extends GenericDao<Cliente>{

	public ClienteDao() {
		super(new Cliente());
		
	}

public Cliente logar(Cliente c){
		
		session =  HibernateUtil.getSessionFactory().openSession();
		Criteria criteria = session.createCriteria(Cliente.class);
		
		criteria.add(Restrictions.eq("email",c.getEmail()));
		criteria.add(Restrictions.eq("senha",c.getSenha()));
		
		Cliente cliente =(Cliente)criteria.uniqueResult();
		session.close();
		
		return cliente;
	}
	
}
